package plochki;

//Simple algorithm, different from BaiIvan only in that it traverses the Figures in reverse order
public class BaiPesho extends BaseWorker{

	public BaiPesho(String inputFile) {
		super(inputFile);
		
		this.name = "BaiPesho";
	}
	
	public BaiPesho(String[] inputFigures) {
		super(inputFigures);
		
		this.name = "BaiPesho";
	}

	//For each Figure if stuck, remove and place on a better spot
	//Traverse the figures in reverse order
	protected void nalepiPlochki() {
		Figura fig;
		for (int i = this.figuri.size() - 1; i >= 0; i--) {
			
			fig = this.figuri.get(i);
			
			//If a figure is stuck with another figure
			if (this.getStuckLevel(fig)>0) {
				//remove from field
				this.otlepiPlochka(fig);
				
				//find a new place for the Figure, the closest possible
				this.findBestPlaceForFigure(fig);
			}
		}
	}
}
